<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>可控组件</title>
</head>
<body>
<script src="../js/react.min.js"></script>
<script src="../js/react-dom.min.js"></script>
<script src="../js/JSXTransformer.js"></script>
<script type="text/jsx">
  "use strict"

  const CiForm = React.createClass({
    getInitialState() {
      return {
        comment: 'Hello CiCi'
      }
    },
    handleChange(event) {
      this.setState({comment: event.target.value})
    },
    handleSubmit(event) {
      event.preventDefault()
      alert(this.state.comment)
    },
    render() {
      console.log(this.state);
      return <form onSubmit={ this.handleSubmit }>
        <input type="text" value={this.state.comment} onChange={this.handleChange}/>
        <button type="submit">speak</button>
      </form>
    }
  })

  ReactDOM.render(<CiForm/>, document.body)

</script>
</body>
</html>